import { ref, computed } from 'vue'
import { defineStore } from 'pinia'


// 组合式
export const useCommonStore = defineStore('commondata', () => {
  // token相关
  const localToken = localStorage.getItem('token') || '';
  const token = ref(localToken)
  const getToken = computed(() => {//用computed 模拟getter
    return token.value || localStorage.getItem('token')
  })
  const updateToken = (ntk) => {
    token.value = ntk
  }
  // 视频相关
  const videoOptions = ref({})// 视频上传前配置，为了使用后端回返回的文件名
  const videoItem = ref({})//单个视频信息

  // 设备枚举状态
  const deviceStatusEnum = ref({})
  // 活动状态枚举
  const activityEnum = ref({});

  // 订单状态枚举
  const orderStatusEnum = ref({})

  // 商家初始化信息配置
  const merchantInitConfig = ref({})

  // 工单状态枚举
  const workorderStatusEnum = ref({})

  // 商家列表
  const merchantList = ref([]);

  // 视频教程状态枚举
  const videoTutorialStatusEnum = ref({})

  // app通知配置
  const appNotifyConfigEnum = ref({})
  const appNotifyConfigItem = ref({})

  return {
    token, getToken, updateToken, videoOptions, videoItem, deviceStatusEnum, activityEnum, orderStatusEnum, merchantInitConfig,
    workorderStatusEnum, merchantList, videoTutorialStatusEnum, appNotifyConfigEnum
  }
})
